import User from "./User";

// 增
const user = {
  name: 'zws',
  age: 18,
  email: '95605355@qq.com'
}
/* const run = new Promise((reject) => {
  const data = new User(user)
  reject(data)
})
run.then(data => {
  const result = data.save()
  console.log(data);
}) */
const insterMethods = async () => {
  const data = new User(user)
  const result = await data.save()
  console.log(result);
}

// 查
const findMethods = async () => {
  const result = await User.find()
  console.log(result);
}

// 改
const updateMethods = async () => {
  const result = await User.updateOne({ name: 'zws' }, {
    email: '956@qq.com'
  })
  console.log(result);
}

// 删
const deleteMethods = async () => {
  const result = await User.deleteOne({ name: 'zws' })
  console.log(result);
}
deleteMethods()
